package com.help10000.rms.ui.adapter

import android.content.Context
import android.widget.ImageView
import com.amir.common.api.ApiContents
import com.amir.common.beans.SaleSheetDetail
import com.amir.common.holder.CommonViewHolder
import com.amir.common.mvp.base.BaseSingleItemTypeRecyclerViewAdapter
import com.amir.common.utils.ImageHelper
import com.help10000.rms.R

class PickingAdapter(mContext: Context, data: List<SaleSheetDetail>, resId: Int) :
    BaseSingleItemTypeRecyclerViewAdapter<SaleSheetDetail>(mContext, data, resId) {


    var pickingDealListener: PickingDealListener? = null

    interface PickingDealListener {
        fun deletePicking(pos: Int)
    }

    override fun bindData(holder: CommonViewHolder, data: SaleSheetDetail, position: Int) {
        var data = dataList[position]
        holder?.setText(R.id.tv_name, data.ItemName)
        holder?.setText(R.id.tv_style, data.ItemStyle)
        holder?.setText(R.id.tv_price, "¥${data.Price}/${data.Unit}")
        holder?.setText(R.id.tv_StockQty, "x${data.Qty}")
        holder?.setOnClickListener(R.id.iv_delete) {
            pickingDealListener?.deletePicking(position)
        }
        var url = "${ApiContents.ImageUrl}${data.Image}"
        var imgThumb = holder.getView<ImageView>(R.id.iv_image);
        ImageHelper.displayImage(mContext, url, imgThumb)
    }

    override fun getItemCount(): Int {
        return dataList.size
    }
}
